package com.lin.mqdemo.activemq.publisher;

import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Component;

import javax.jms.Destination;


/**
 * 发布者
 *
 * @author lin
 * @date 2018年8月29日
 */
@Component
public class Publisher {

    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    public void publish(){
        Destination destination = new ActiveMQTopic("topic");
        System.out.println("发送topic");
        jmsMessagingTemplate.convertAndSend(destination,"topic");
    }
}
